#!/usr/bin/env python
# -*- coding: utf-8 -*-

###########################################################
#                                                         #
# shooter - shooter game                                  #
#                                                         #
# 2011 - Andreas Grätz                                    #
#                                                         #
# andreaszdw@googlemail.com                               #
#                                                         #
# shtr.py                                                 #
#                                                         #
###########################################################

import gameengine
import menustate

running = True

# start the engine
game = gameengine.GameEngine()

#push Menustate to the top of the stack
game.pushState(menustate.MenuState())

while(running):
	#save current state for test if running or changing the state
	currentState = game.top()
	
	#do the loop
	game.handleevents()
	game.update()
	game.draw()
	
	#test if state is running
	running = game.isrunning()
	
	#test for changing state
	# here a new state
	if currentState.nextState:
		tmpState = currentState.nextState
		currentState.nextState = False
		game.pushState(tmpState())
	
	#here resume previous state
	if currentState.popState:
		currentState.popState = False
		game.popState()
		
game.cleanup()
